<template>
	<view>
		<view class=" grid col-1  ">
			<view class="padding-sm">
				<view class="padding-sm radius text-center bg-gradual-red">
					<view class="uni-h5">{{i18n.sum.hascoin}}</view>
					<view class=" text-Abc">
						<label class="uni-h5">{{userinfo.wall2}}</label>
					</view>
				</view>
			</view>
		</view>
		<view class=" grid col-2  ">
			<view class="padding-sm">
				<view class="padding-sm radius text-center bg-gradual-yellow">
					<view class="uni-h5">{{i18n.sum.Yesterday}}</view>
					<view class=" text-Abc">
						<label class="uni-h5">{{yesttotal}}</label>
					</view>
				</view>
			</view>

			<view class="padding-sm">
				<view class="padding-sm radius text-center bg-gradual-purple">
					<view class="uni-h5">{{i18n.sum.Cumulative}}</view>
					<view class=" text-Abc">
						<label class="uni-h5">{{ljtotal}}</label>
					</view>
				</view>
			</view>

		</view>

		<view class=" grid col-1  ">
			<view class="padding-sm">
				<view class=" radius text-center bg-gradual-orange">
					<view class=" grid col-2 ">
						<view class="padding-sm">
							<image src="../../static/huang.png" style="height: 39px;width: 39px;"></image>
							<view class=" text-center ">
								<view class="uni-h5">{{i18n.sum.holdingArea}}</view>
							</view>
						</view>
						<view class="padding-sm">
							<view class=" text-center ">
								<view class="uni-h5" style="
    padding: 9px;
">{{i18n.sum.Holding}}：{{info.wall3}}</view>
								<!-- <view class="uni-h5">{{i18n.sum.holdsort}}：{{info.S1}} </view> -->
								<view class="uni-h5">{{i18n.sum.IncomeRate}}{{info.rate}}%</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
 
		 
		<!-- <view class="padding bg-white">
			<view class="flex">
				<view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
				<view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
			</view>
			<view class="flex  p-xs margin-bottom-sm mb-sm">
				<view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
				<view class="flex-twice bg-grey padding-sm margin-xs radius">2</view>
			</view>
			<view class="flex  p-xs margin-bottom-sm mb-sm">
				<view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
				<view class="flex-twice bg-grey padding-sm margin-xs radius">2</view>
				<view class="flex-treble bg-grey padding-sm margin-xs radius">3</view>
			</view>
		</view> -->
		<view class="flex">
			<view class="flex-treble padding-sm">
				<view class="   ">
					<view class="uni-h4">{{i18n.sum.YesterdayIncomeAndDate}}</view>
					<!-- <view class="text-gray text-sm">{{i18n.sum.SnapshotCalculation}}</view> -->
				</view>
			</view>
			<view class="flex-sub padding-sm">
				<view class=" text-right ">
					<view class="uni-h5">{{zuo}}</view>
				</view>
			</view>
		</view>
		<view class="text-gray text-sm padding-sm">{{i18n.sum.SnapshotCalculation}}</view>
		<view class="cu-list menu card-menu margin-bottom" :class="['sm-border','margin-top']">

			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.NumberOfPositions}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.kzwall3}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.PositionIncome}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.B1yest}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.IncomeRate}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{rate1}}%</text>
				</view>
			</view>
			<!-- <view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.mysort}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.S1}}</text>
				</view>
			</view> -->
		</view>


		<view class="flex">
			<view class="flex-treble padding-sm">
				<view class="   ">
					<view class="uni-h4">{{i18n.sum.YesterdayPromotionRevenue}}</view>
					<!-- <view class="text-gray text-sm">根据昨日随机快照计算</view> -->
				</view>
			</view>
			<view class="flex-sub padding-sm">
				<view class=" text-right ">
					<view class="uni-h5">{{zuo}}</view>
				</view>
			</view>
		</view>
		<view class="cu-list menu card-menu margin-bottom" :class="['sm-border','margin-top']">

			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.PromoteComputingPower}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.suan}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.PromotionRevenue}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.B3yest}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.EffectiveNumber}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.ztnum}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.extraBonus}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">0</text>
				</view>
			</view>

		</view>

		<view class="flex">
			<view class="flex-treble padding-sm">
				<view class="   ">
					<view class="uni-h4">{{i18n.sum.YesterdayTotalTransactionAmount}}</view>
					<!-- <view class="text-gray text-sm">根据昨日随机快照计算</view> -->
				</view>
			</view>
			<view class="flex-sub padding-sm">
				<view class=" text-right ">
					<view class="uni-h5">{{zuo}}</view>
				</view>
			</view>
		</view>
		<view class="cu-list menu card-menu margin-bottom" :class="['sm-border','margin-top']">

			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.total}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.kzgryj}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.income}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.B2yest}}</text>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.IncomeRate}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{rate2}}%</text>
				</view>
			</view>
			<!-- <view class="cu-item ">
				<view class="content">
					<text class="text-grey">{{i18n.sum.mysort}} </text>
				</view>
				<view class="action">
					<text class=" text-gray">{{userinfo.S2}}</text>
				</view>
			</view> -->
		</view>


	</view>
</template>
<script>
	import {
		mapState,
		mapActions
	} from 'vuex';
	let startY = 0,
		moveY = 0,
		pageAtTop = true;
	export default {
		data() {
			return {
				info: {}
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
            	title: this.i18n.sum.title
        	});
		},

		computed: {
			...mapState({
				userinfo: state => state.user.userinfo,
				myconfig: state => state.user.myconfig
			}),
			hasLogin() {
				return this.userinfo.id ? true : false
			},
			zuo() {
				var day1 = new Date();
				day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000);
				return day1.getFullYear() + "-" + (day1.getMonth() + 1) + "-" + day1.getDate();
			},
			rate1() {
				return this.userinfo.kzwall3 > 0 ? Math.round(this.userinfo.B1yest / this.userinfo.kzwall3 * 100) / 100 : 0
			},
			rate2() {
				return this.userinfo.kzgryj > 0 ? Math.round(this.userinfo.B2yest / this.userinfo.kzgryj * 100) / 100 : 0
			},
			yesttotal() {
				var total = this.accAdd(this.userinfo.B1yest,this.userinfo.B2yest);
			 
				return this.accAdd(total,this.userinfo.B3yest);
			},
			ljtotal() {
				var total = this.accAdd(this.userinfo.B1total,this.userinfo.B2total);
			 
				return this.accAdd(total,this.userinfo.B3total);
			},
			i18n() {
				return this.$t('message');
			}
		},
		methods: {
			...mapActions(['getUserinfo']),
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				if (!this.userinfo.id) {
					url = '/pages/public/login';
				}
				uni.navigateTo({
					url
				})
			},
			//加法
			accAdd(arg1, arg2) {
				var r1, r2, m, n;
				try {
					r1 = arg1.toString().split(".")[1].length
				} catch (e) {
					r1 = 0
				}
				try {
					r2 = arg2.toString().split(".")[1].length
				} catch (e) {
					r2 = 0
				}
				m = Math.pow(10, Math.max(r1, r2));
				//last modify by deeka
				//动态控制精度长度
				n = (r1 >= r2) ? r1 : r2;
				var ree = ((arg1 * m + arg2 * m) / m).toFixed(n);
				return ree > 0 ? ree : 0;
			},
			
		},
		onShow() {
			this.getUserinfo();
			this.$http.post('index.best').then(res => {
				if(res.code==1){
					
					this.info = res.data
					this.info.rate=res.data.kzwall3 > 0 ? Math.round(res.data.B1yest / res.data.kzwall3 * 100) / 100 : 0
				}
				
			});
		},
	}
</script>
<style lang='scss'>
	image {
		display: inline-block;
		width: 120upx;
		height: 120upx;
		margin: 5upx;
		border-radius: 30upx;
	}
</style>
